knitr::opts_chunk$set(echo = TRUE)
rm(list = ls())
cat("\014")
library(vroom)
library(tidyverse)
library(haven)
library(ggthemes)
data <- vroom("yale_climate_opinion_data.csv")
head(data)
data <- data %>%
filter(year == 2020) %>%
dplyr::select(cty_fips, countyname, statename, year, CO2limits, fundrenewables,
supportRPS, regulate)
irr <- vroom("IRR_2000_2020.csv")
head(irr)
irr <- irr %>%
rename(cty_fips = FIPS2020) %>%
dplyr::select(cty_fips, IRR2020
)
data <- left_join(data, irr, by = "cty_fips")
library(scales)
data %>%
ggplot(aes(x = IRR2020, y = supportRPS / 100)) +
geom_point(size = 0.5, alpha = 0.3) +
geom_smooth(method = "lm") +
theme_clean() +
xlab("Relative Rurality in 2020") +
ylab("Level of Support for RPS in 2020") +
scale_y_continuous(labels = label_percent())
ggsave("support.rps.png",
width = 8, height = 8/1.618, units = "in")
corr(data$IRR2020, data$supportRPS)
cor(data$IRR2020, data$supportRPS)
cor(data$IRR2020, data$supportRPS, na.omit())
cor(data$IRR2020, data$supportRPS, use = "complete.obs")
